﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Research.DynamicDataDisplay.DataSources;
using Microsoft.Research.DynamicDataDisplay;

namespace WpfApplicationWithGrid
{
    class DataVisualize
    {
        readonly public static int[] xaxix = new int[30];
        readonly public static float[] success_yaxix = new float[30];
        readonly public static float[] hit_yaxix = new float[30];
        readonly public static float[] avg_yaxix = new float[30];
        public static EnumerableDataSource<int> xSrc = new EnumerableDataSource<int>(xaxix);
        public static EnumerableDataSource<float> successSrc = new EnumerableDataSource<float>(success_yaxix);
        public static EnumerableDataSource<float> hitSrc = new EnumerableDataSource<float>(hit_yaxix);
        public static EnumerableDataSource<float> avgSrc = new EnumerableDataSource<float>(avg_yaxix);
        public static void init()
        {
            for (int i = 0; i < 30; i++)
            {
                xaxix[i] = i;
            }
                xSrc.SetXMapping(x => x);
            successSrc.SetYMapping(y => y);
            hitSrc.SetYMapping(y => y);
            avgSrc.SetYMapping(y => y);
        }

        public static void dataUpdate()
        {
            successSrc.RaiseDataChanged();
            hitSrc.RaiseDataChanged();
            avgSrc.RaiseDataChanged();
        }

        public static void AddSuccessRatio(float value)
        {
            for (int i = 0; i < 29; i++)
            {
                success_yaxix[i] = success_yaxix[i + 1];
            }
            success_yaxix[29] = value;
        }

        public static void AddHitRatio(float value)
        {
            for (int i = 0; i < 29; i++)
            {
                hit_yaxix[i] = hit_yaxix[i + 1];
            }
            hit_yaxix[29] = value;
        }

        public static void AddAvgRatio(float value)
        {
            for (int i = 0; i < 29; i++)
            {
                avg_yaxix[i] = avg_yaxix[i + 1];
            }
            avg_yaxix[29] = value;
        }
    }
}
